/*********************
* Author:Dzlua
* QQ:505544956
* time:2016/05/03
*/
#ifndef __EDUI_IFONT_H__
#define __EDUI_IFONT_H__

#include "../core/Base.h"

EDUI_NAMESPACE_BEGIN

class IRender;
class ITexture;
	
class EDUI_API IFont
{
public:
    virtual void Release() = 0;
public:
	/* if not name.
	       Create("font.ttf", 12, 0);
	   add to mgr as: default name is "font.ttf-12"
	*/
	virtual bool Create(const char* file, int size, const char* name = 0, int id = -1) = 0;

	/* if not name.
	       Create("font.ttf", 12, 1, 0);
	   add to mgr as: default name is "font.ttf-12-1"
	*/
	virtual bool Create(const char* file, int size, long idx, const char* name = 0, int id = -1) = 0;

	virtual bool IsOK() = 0;
	virtual void Destroy() = 0;

	virtual int GetHeight() = 0;

	/* Set and retrieve the font style */
	virtual void SetStyle(int style) = 0;
	virtual int  GetStyle() = 0;
	virtual void SetOutline(int outline) = 0;
	virtual int  GetOutline() = 0;
	virtual void SetStyle(bool bold, bool italic, bool underline, bool strikethrough) = 0;

	/* Set and retrieve FreeType hinter settings */
	virtual void SetHinting(FontHinting hinting) = 0;
	virtual FontHinting GetHinting() = 0;

	/* Get the offset from the baseline to the top of the font
	This is a positive value, relative to the baseline.
	*/
	virtual int Ascent() = 0;

	/* Get the offset from the baseline to the bottom of the font
	This is a negative value, relative to the baseline.
	*/
	virtual int Descent() = 0;

	/* Get the recommended spacing between lines of text for this font */
	virtual int LineSkip() = 0;

	/* Get/Set whether or not kerning is allowed for this font */
	virtual void SetKerning(bool allowed) = 0;
	virtual int GetKerning() = 0;

	/* Get the number of faces of the font */
	virtual long Faces() = 0;

	/* Get the font face attributes, if any */
	virtual int  FaceIsFixedWidth() = 0;
	virtual char* FaceFamilyName() = 0;
	virtual char* FaceStyleName() = 0;

	/* Check wether a glyph is provided by the font or not */
	virtual int GlyphIsProvided(Uint16 ch) = 0;

	/* Get the metrics (dimensions) of a glyph
	   To understand what these metrics mean, here is a useful link:
	   http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
	*/
	virtual int GlyphMetrics(Uint16 ch, int *minx, int *maxx,
                              int *miny, int *maxy, int *advance) = 0;

	/* Get the dimensions of a rendered string of text */
	virtual Size GetSize(const char *text) = 0;
	virtual Size GetSizeUTF8(const char *text) = 0;
	virtual Size GetSizeUNICODE(const Uint16 *text) = 0;

	/* Get the kerning size of two glyphs */
	virtual int GetKerningSizeGlyphs(Uint16 previous_ch, Uint16 ch) = 0;

	virtual ITexture* RenderText(IRender* render, const char* text, const Color* fg) = 0;
};

EDUI_NAMESPACE_END

#endif